<template>
  <div>
    <el-table
      :data="tableData"
      >
      <el-table-column
        prop="code"
        label="编号"
        >
      </el-table-column>
      <el-table-column
        prop="descrip"
        label="描述"
        >
      </el-table-column>
      <el-table-column
        prop="purpose"
        label="借款用途"
        >
      </el-table-column>
      <el-table-column
        prop="tmoney"
        label="借款总额">
      </el-table-column>
      <el-table-column
        prop="pay_type"
        label="还款方式"
        :formatter="aa"
        >
      </el-table-column>
      <el-table-column
        prop="interest_rate"
        label="借款利率">
      </el-table-column>
      <el-table-column
        prop="term"
        label="借款期限"
        
        >
      </el-table-column>
      <el-table-column
        prop="userid"
        label="用户">
      </el-table-column>
      <el-table-column
        prop=""
        label="评论">
        <template slot-scope="scope">
        <el-button @click="pl(scope.row.code)">评论</el-button>
    </template>
      </el-table-column>
      <el-table-column
        prop=""
        label="查看">
        <template slot-scope="scope">
        <el-button @click="ck(scope.row.code)">查看</el-button>
    </template>
      </el-table-column>
    </el-table>
    <van-pagination v-model="page" :total-items="total" :items-per-page="page_size" @change="getclandmarks"/>
    <el-dialog title="评论" :visible.sync="dialogTableVisible">
        <el-input placeholder="品论" v-model="content"></el-input>
        <el-button @click="tj">提交</el-button>
    </el-dialog>

    <el-dialog title="查看" :visible.sync="dialog1">
        <el-table
      :data="data"
      >
      <el-table-column
        prop="userid"
        label="评论人"
        >
      </el-table-column>
      <el-table-column
        prop="username"
        label="评论人姓名"
        >
      </el-table-column>
      <el-table-column
        prop="create_time"
        label="评论时间">
      </el-table-column>
      <el-table-column
        prop="content"
        label="评论">
      </el-table-column>
      <el-table-column
        prop="dish_id"
        label="标的编号">
      </el-table-column>
    </el-table>
    </el-dialog>
  
  </div>
</template>

<script>
export default {
    data(){
        return{
            userid:localStorage.getItem("uid"),
    
            tableData:"",
            total:0,
            page_size:2,
            page:1,
            code:0,
            content:"",
            dialogTableVisible:false,
            dialog1:false,
            data:""
        }
    },
    methods:{
        getclandmarks(){
            this.axios.get("/clandmarks?&page="+this.page + "&page_size="+this.page_size).then(res =>{
                this.tableData = res.data.data
                this.total = res.data.total
            })
        },
        pl(code){
            this.code=code
            this.dialogTableVisible=true
    },
    tj(){
        var data = {"userid":this.userid,"content":this.content,"dish_id":this.code}
        this.axios.post("/Evaluate",data).then(res =>{
            console.log(">>",data)
            alert(res.data.msg)
        })
    },
    ck(code){
        this.dialog1 = true
        this.axios.get("/Evaluate?code="+code).then(res =>{
            this.data = res.data.data
        })
    }
    },
    mounted(){
        this.getclandmarks()
    },
    

}
</script>

<style>

</style>